home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2346 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  940 b 

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: quick decision: is n a power of 2?
  5. Date: 20 Jan 1996 11:04:28 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4dr7as$s1@solutions.solon.com>
  8. References: <4dorr8$i58@cloner3.netcom.com> <4dp2no$3va@unix.sri.com> <TANMOY.96Jan19220222@qcd.lanl.gov>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <TANMOY.96Jan19220222@qcd.lanl.gov>,
  12. Tanmoy Bhattacharya <tanmoy@qcd.lanl.gov> wrote:
  13. >Don't think, try
  14.  
  15. >#define POWER(x) (!((x) & ((x)-1)))
  16.  
  17. >on unsigned types.
  18.  
  19. It reports that 0 is a power of 2.
  20.  
  21. Very clever, though.
  22.  
  23. -s
  24. -- 
  25. Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
  26. C/Unix proto-wizard -- C/Unix questions? Send mail for help.  No, really!
  27. Using trn?  Weird new newsgroup problem?  I know the fix!  Email me!
  28. The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy
  29.